{smcl}
{com}{sf}{ul off}{txt}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\thies\OneDrive\00_Promotion\00_Output\00_Paper\2022_Predicting_Econ_Sanctions\Empirics\20231214_Replication\Log_files/01a_Imposition_limited_sample_US.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res}18 Dec 2023, 16:04:34
{txt}
{com}. 
. ***************************************************************
. ***US***
. ***************************************************************
. 
. set seed 1234
{txt}
{com}. 
. *Prepare data
. use "Dataset.dta", clear
{txt}
{com}. keep if sender=="US"
{txt}(10,154 observations deleted)

{com}. 
. ** Filter for cases of importance
. keep if pot_sanctioned_countries == 1
{txt}(1,296 observations deleted)

{com}. 
. * Independent Variables
. gen ln_oil_gas_value_2014 = ln(oil_gas_value_2014+1)
{txt}(197 missing values generated)

{com}. gen sender_colony=US_colony
{txt}(13 missing values generated)

{com}. gen sender_trade = ln_US_Trade_COW
{txt}(234 missing values generated)

{com}. gen coup_dummy = coup1
{txt}(5 missing values generated)

{com}. replace coup_dummy = 0 if coup_dummy == 1
{txt}(61 real changes made)

{com}. replace coup_dummy = 1 if coup_dummy == 2
{txt}(45 real changes made)

{com}. 
. * Dependent variable: 1 if a threat or sanction case was ongoing in the dyad
. gen sanction_threat = sanction_dyad
{txt}
{com}. replace sanction_threat = 1 if threat_dyad==1
{txt}(179 real changes made)

{com}. tab sanction_threat

{txt}sanction_th {c |}
       reat {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
          0 {c |}{res}      2,793       73.87       73.87
{txt}          1 {c |}{res}        988       26.13      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}      3,781      100.00
{txt}
{com}. gen sanction_train= sanction_threat if year < 2009
{txt}(992 missing values generated)

{com}. gen sanction_test= sanction_threat if year >= 2009
{txt}(2,789 missing values generated)

{com}. 
. * lag time-series variables
. sort ccodecow year
{txt}
{com}. by ccodecow: gen l_v2x_polyarchy = v2x_polyarchy[_n-1] if year==year[_n-1]+1
{txt}(240 missing values generated)

{com}. by ccodecow: gen l_gd_ptss = gd_ptss[_n-1] if year==year[_n-1]+1
{txt}(225 missing values generated)

{com}. by ccodecow: gen l_coup_dummy = coup_dummy[_n-1] if year==year[_n-1]+1
{txt}(151 missing values generated)

{com}. by ccodecow: gen l_one_sided_violence = one_sided_violence[_n-1] if year==year[_n-1]+1
{txt}(147 missing values generated)

{com}. by ccodecow: gen l_conflict = conflict[_n-1] if year==year[_n-1]+1
{txt}(147 missing values generated)

{com}. by ccodecow: gen l_mid_terr_integrity = mid_terr_integrity[_n-1] if year==year[_n-1]+1
{txt}(147 missing values generated)

{com}. by ccodecow: gen l_ln_GDPpc_imputed = ln_GDPpc_imputed[_n-1] if year==year[_n-1]+1
{txt}(187 missing values generated)

{com}. by ccodecow: gen l_sender_trade = sender_trade[_n-1] if year==year[_n-1]+1
{txt}(237 missing values generated)

{com}. by ccodecow: gen l_ln_oil_gas_value = ln_oil_gas_value_2014[_n-1] if year==year[_n-1]+1
{txt}(202 missing values generated)

{com}. by ccodecow: gen l_defense_alliance = defense_alliance[_n-1] if year==year[_n-1]+1
{txt}(147 missing values generated)

{com}. 
. * create dummy variables
. tabulate l_gd_ptss, generate (pol_terr)

  {txt}l_gd_ptss {c |}      Freq.     Percent        Cum.
{hline 12}{c +}{hline 35}
          1 {c |}{res}        465       13.08       13.08
{txt}          2 {c |}{res}      1,009       28.37       41.45
{txt}          3 {c |}{res}      1,190       33.46       74.92
{txt}          4 {c |}{res}        634       17.83       92.74
{txt}          5 {c |}{res}        258        7.26      100.00
{txt}{hline 12}{c +}{hline 35}
      Total {c |}{res}      3,556      100.00
{txt}
{com}. 
. * sortieren nach Jahr, zur Vorbereitung RF model
. gen u=0
{txt}
{com}. replace u=1 if year >= 2009
{txt}(992 real changes made)

{com}. sort u
{txt}
{com}. 
. ** Imposition
. * Random Forest Model
. rforest sanction_threat l_v2x_polyarchy pol_terr* l_coup_dummy ///
> l_one_sided_violence l_conflict l_mid_terr_integrity ///
> l_ln_GDPpc_imputed l_sender_trade l_ln_oil_gas_value ///
> sender_colony l_defense_alliance in 1/2789, type(class) iter(1500) numvars(15)
{txt}
{com}. 
. * Variable Importance
. ereturn list

{txt}scalars:
       e(Observations) =  {res}2789
           {txt}e(features) =  {res}15
         {txt}e(Iterations) =  {res}1500
          {txt}e(OOB_Error) =  {res}.1165292219433489

{txt}macros:
                e(cmd) : "{res}rforest{txt}"
            e(predict) : "{res}randomforest_predict{txt}"
             e(depvar) : "{res}sanction_threat{txt}"
         e(model_type) : "{res}random forest classification{txt}"

matrices:
         e(importance) : {res} 15 x 1
{txt}
{com}. matrix list e(importance)
{res}
{txt}e(importance)[15,1]
              Variable I~e
l_v2x_poly~y {res}    .86461223
{txt}   pol_terr1 {res}    .38395818
{txt}   pol_terr2 {res}    .82920445
{txt}   pol_terr3 {res}            1
{txt}   pol_terr4 {res}    .74386509
{txt}   pol_terr5 {res}    .62434115
{txt}l_coup_dummy {res}    .70966372
{txt}l_one_side~e {res}    .80956874
{txt}  l_conflict {res}     .7687427
{txt}l_mid_terr~y {res}    .76041528
{txt}l_ln_GDPpc~d {res}    .86477637
{txt}l_sender_t~e {res}    .81921755
{txt}l_ln_oil_g~e {res}    .70050265
{txt}sender_col~y {res}    .00467976
{txt}l_defense_~e {res}    .56998428
{reset}
{com}. * write Variable importance to excel file
. putexcel set "Supplemental_Material\Variable_Importance\Variable_Importance_Imposition_US_RF.xlsx", sheet("M") replace
{res}{txt}Note: File will be replaced when the first {cmd:putexcel} command is issued.

{com}. putexcel A1=matrix(e(importance)), names
{res}{txt}file {bf:Supplemental_Material\Variable_Importance\Variable_Importance_Imposition_US_RF.xlsx} saved

{com}. 
. * Predictions
. predict randonsUS
{txt}
{com}. predict randonsUS0 randonsUS1, pr
{txt}
{com}. 
. * Confusion Matrix
. * Sensitivity 53.2, Specificity 87.3
. diagtest sanction_test randonsUS

{txt}sanction_t {c |}   predicted classes
       est {c |}         0          1 {c |}     Total
{hline 11}{c +}{hline 22}{c +}{hline 10}
         0 {c |}{res}       700         89 {txt}{c |}{res}       789 
{txt}         1 {c |}{res}       102        101 {txt}{c |}{res}       203 
{txt}{hline 11}{c +}{hline 22}{c +}{hline 10}
     Total {c |}{res}       802        190 {txt}{c |}{res}       992 

{txt}True D defined as randonsUS ~= 0                      [95% Conf. Inter.]
-------------------------------------------------------------------------
Sensitivity                     Pr( +| D)  {res}53.16%      50.05%   56.26%
{txt}Specificity                     Pr( -|~D)  {res}87.28%      85.21%   89.36%
{txt}Positive predictive value       Pr( D| +)  {res}49.75%      46.64%   52.87%
{txt}Negative predictive value       Pr(~D| -)  {res}88.72%      86.75%   90.69%
{txt}-------------------------------------------------------------------------
Prevalence                      Pr(D)      {res}19.15%      16.70%   21.60%
{txt}-------------------------------------------------------------------------

{com}. tab2xl sanction_test randonsUS using Main_Article\US_Imposition_RF_Confusion_Matrix, row(1) col(1)
{res}{txt}file {bf:Main_Article\US_Imposition_RF_Confusion_Matrix.xlsx} saved

{com}. 
. * Kappa .41
. kap sanction_test randonsUS

{txt}{col 14}Expected
Agreement   agreement     Kappa   Std. err.         Z      Prob>Z
{hline 65}
{res}  80.75%      68.22%     0.3941     0.0317      12.42      0.0000
{txt}
{com}. 
. * AUPR .52
. prtab sanction_test randonsUS1, title("US", box bexpand) 
{txt}(2 missing values generated)

{col 12}Number of observations       =  {res}992
{txt}{col 12}Unique values of classifier  =  {res}918
{txt}{col 12}Number of positive cases     =  {res}203
{txt}{col 12}Portion of positive cases    ={res}  0.2046

{txt}{hline 50}
{col 5} Recall =  0.1034{col 25}  0.2020{col 37}  0.3005
{hline 50}
{res}{col 2}Precision{col 14}  0.7241{col 25}  0.6721{col 37}  0.6630
{txt}{hline 50}
{res}
{txt}{col 2}Area under precision-recall curve:  0.5150

{com}. graph save "Graph" "Supplemental_Material\Prediction_Output\ROC-curves\AUPR_Imposition_RF_US.gph", replace
{txt}{p 0 4 2}
(file {bf}
Supplemental_Material\Prediction_Output\ROC-curves\AUPR_Imposition_RF_US.gph{rm}
not found)
{p_end}
{res}{txt}file {bf:Supplemental_Material\Prediction_Output\ROC-curves\AUPR_Imposition_RF_US.gph} saved

{com}. 
. 
. *******************************************************************
. ******* Compare to logistic regression ability ********************
. *******************************************************************
. 
. sort ccodecow year
{txt}
{com}. egen sum_sanction = sum(sanction_dyad), by(ccodecow)
{txt}
{com}. gen dum_country = ccodecow
{txt}
{com}. replace dum_country = 0 if sum_sanction==0
{txt}(1,607 real changes made)

{com}. xtset ccodecow year
{res}
{col 1}{txt:Panel variable: }{res:ccodecow}{txt: (unbalanced)}
{p 1 16 2}{txt:Time variable: }{res:year}{txt:, }{res:{bind:1989}}{txt: to }{res:{bind:2015}}{p_end}
{txt}{col 10}Delta: {res}1 unit
{txt}
{com}. 
. * Original
. brglm sanction_train L.v2x_polyarchy i.L.gd_ptss i.L.coup_dummy i.L.one_sided_violence i.L.conflict i.L.mid_terr_integrity L.ln_GDPpc_imputed L.sender_trade L.ln_oil_gas_value_2014 i.L.sender_colony i.L.defense_alliance i.dum_country i.year, vce(cluster ccodecow)
{res}{txt}Iteration 1    tol = {res}.01381223
{txt}Iteration 2    tol = {res}.03923999
{txt}Iteration 3    tol = {res}.01593974
{txt}Iteration 4    tol = {res}.00111292
{txt}Iteration 5    tol = {res}.00003749
{txt}Iteration 6    tol = {res}7.135e-07

{txt}Biased-reduced probit glm regression{col 51}No. of obs{col 67}={col 69}{res}     2,417


{txt}Log-likelihood: {res}-4888.1611

{txt}{hline 22}{c TT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12}
{col 1}       sanction_train{col 23}{c |} Coefficient{col 35}  Std. err.{col 47}      z{col 55}   P>|z|{col 63}     [95% con{col 76}f. interval]
{hline 22}{c +}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12}
{space 8}v2x_polyarchy {c |}
{space 18}L1. {c |}{col 23}{res}{space 2}-.5557731{col 35}{space 2}  .677017{col 46}{space 1}   -0.82{col 55}{space 3}0.412{col 63}{space 4}-1.882702{col 76}{space 3} .7711559
{txt}{space 21} {c |}
{space 12}L.gd_ptss {c |}
{space 19}2  {c |}{col 23}{res}{space 2} .2099861{col 35}{space 2} .2104458{col 46}{space 1}    1.00{col 55}{space 3}0.318{col 63}{space 4}-.2024801{col 76}{space 3} .6224523
{txt}{space 19}3  {c |}{col 23}{res}{space 2}  .354223{col 35}{space 2} .2699768{col 46}{space 1}    1.31{col 55}{space 3}0.190{col 63}{space 4}-.1749218{col 76}{space 3} .8833678
{txt}{space 19}4  {c |}{col 23}{res}{space 2} .7023016{col 35}{space 2} .3239536{col 46}{space 1}    2.17{col 55}{space 3}0.030{col 63}{space 4} .0673643{col 76}{space 3} 1.337239
{txt}{space 19}5  {c |}{col 23}{res}{space 2} .8614996{col 35}{space 2} .3602538{col 46}{space 1}    2.39{col 55}{space 3}0.017{col 63}{space 4} .1554152{col 76}{space 3} 1.567584
{txt}{space 21} {c |}
{space 9}L.coup_dummy {c |}
{space 19}1  {c |}{col 23}{res}{space 2} .7395445{col 35}{space 2} .2609696{col 46}{space 1}    2.83{col 55}{space 3}0.005{col 63}{space 4} .2280535{col 76}{space 3} 1.251036
{txt}{space 21} {c |}
{space 1}L.one_sided_violence {c |}
{space 19}1  {c |}{col 23}{res}{space 2} .1262804{col 35}{space 2} .1670864{col 46}{space 1}    0.76{col 55}{space 3}0.450{col 63}{space 4} -.201203{col 76}{space 3} .4537638
{txt}{space 21} {c |}
{space 11}L.conflict {c |}
{space 19}1  {c |}{col 23}{res}{space 2}-.1679087{col 35}{space 2} .1797853{col 46}{space 1}   -0.93{col 55}{space 3}0.350{col 63}{space 4}-.5202814{col 76}{space 3} .1844641
{txt}{space 21} {c |}
{space 1}L.mid_terr_integrity {c |}
{space 19}1  {c |}{col 23}{res}{space 2} .2884777{col 35}{space 2}  .272315{col 46}{space 1}    1.06{col 55}{space 3}0.289{col 63}{space 4}-.2452498{col 76}{space 3} .8222052
{txt}{space 21} {c |}
{space 5}ln_GDPpc_imputed {c |}
{space 18}L1. {c |}{col 23}{res}{space 2} .0846159{col 35}{space 2} .1217412{col 46}{space 1}    0.70{col 55}{space 3}0.487{col 63}{space 4}-.1539924{col 76}{space 3} .3232242
{txt}{space 21} {c |}
{space 9}sender_trade {c |}
{space 18}L1. {c |}{col 23}{res}{space 2}-.0316424{col 35}{space 2} .0700518{col 46}{space 1}   -0.45{col 55}{space 3}0.651{col 63}{space 4}-.1689415{col 76}{space 3} .1056566
{txt}{space 21} {c |}
ln_oil_gas_value_2014 {c |}
{space 18}L1. {c |}{col 23}{res}{space 2} .0284757{col 35}{space 2} .0142777{col 46}{space 1}    1.99{col 55}{space 3}0.046{col 63}{space 4} .0004919{col 76}{space 3} .0564594
{txt}{space 21} {c |}
{space 6}L.sender_colony {c |}
{space 19}1  {c |}{col 23}{res}{space 2} .0840334{col 35}{space 2} .3704227{col 46}{space 1}    0.23{col 55}{space 3}0.821{col 63}{space 4}-.6419818{col 76}{space 3} .8100485
{txt}{space 21} {c |}
{space 3}L.defense_alliance {c |}
{space 19}1  {c |}{col 23}{res}{space 2}-.6830942{col 35}{space 2} .3734567{col 46}{space 1}   -1.83{col 55}{space 3}0.067{col 63}{space 4}-1.415056{col 76}{space 3} .0488675
{txt}{space 21} {c |}
{space 10}dum_country {c |}
{space 18}40  {c |}{col 23}{res}{space 2} 2.527984{col 35}{space 2} .3073291{col 46}{space 1}    8.23{col 55}{space 3}0.000{col 63}{space 4}  1.92563{col 76}{space 3} 3.130338
{txt}{space 18}41  {c |}{col 23}{res}{space 2}  4.05338{col 35}{space 2} .4420674{col 46}{space 1}    9.17{col 55}{space 3}0.000{col 63}{space 4} 3.186944{col 76}{space 3} 4.919816
{txt}{space 18}52  {c |}{col 23}{res}{space 2} 2.479251{col 35}{space 2} .2569565{col 46}{space 1}    9.65{col 55}{space 3}0.000{col 63}{space 4} 1.975625{col 76}{space 3} 2.982876
{txt}{space 18}70  {c |}{col 23}{res}{space 2} 1.476238{col 35}{space 2} .4161224{col 46}{space 1}    3.55{col 55}{space 3}0.000{col 63}{space 4} .6606533{col 76}{space 3} 2.291823
{txt}{space 18}90  {c |}{col 23}{res}{space 2} 3.103207{col 35}{space 2} .3197827{col 46}{space 1}    9.70{col 55}{space 3}0.000{col 63}{space 4} 2.476444{col 76}{space 3} 3.729969
{txt}{space 18}91  {c |}{col 23}{res}{space 2} 1.651279{col 35}{space 2} .3853104{col 46}{space 1}    4.29{col 55}{space 3}0.000{col 63}{space 4} .8960842{col 76}{space 3} 2.406473
{txt}{space 18}92  {c |}{col 23}{res}{space 2} 2.069002{col 35}{space 2}  .371676{col 46}{space 1}    5.57{col 55}{space 3}0.000{col 63}{space 4} 1.340531{col 76}{space 3} 2.797474
{txt}{space 18}93  {c |}{col 23}{res}{space 2} 2.147852{col 35}{space 2} .3814639{col 46}{space 1}    5.63{col 55}{space 3}0.000{col 63}{space 4} 1.400196{col 76}{space 3} 2.895507
{txt}{space 18}95  {c |}{col 23}{res}{space 2} 2.467312{col 35}{space 2} .3446701{col 46}{space 1}    7.16{col 55}{space 3}0.000{col 63}{space 4} 1.791771{col 76}{space 3} 3.142853
{txt}{space 17}100  {c |}{col 23}{res}{space 2} 1.767834{col 35}{space 2} .3759484{col 46}{space 1}    4.70{col 55}{space 3}0.000{col 63}{space 4} 1.030989{col 76}{space 3}  2.50468
{txt}{space 17}101  {c |}{col 23}{res}{space 2} 1.959784{col 35}{space 2} .3461341{col 46}{space 1}    5.66{col 55}{space 3}0.000{col 63}{space 4} 1.281374{col 76}{space 3} 2.638194
{txt}{space 17}130  {c |}{col 23}{res}{space 2} 2.703824{col 35}{space 2} .2778146{col 46}{space 1}    9.73{col 55}{space 3}0.000{col 63}{space 4} 2.159317{col 76}{space 3}  3.24833
{txt}{space 17}135  {c |}{col 23}{res}{space 2} 3.414586{col 35}{space 2} .3070666{col 46}{space 1}   11.12{col 55}{space 3}0.000{col 63}{space 4} 2.812747{col 76}{space 3} 4.016426
{txt}{space 17}140  {c |}{col 23}{res}{space 2} 1.765284{col 35}{space 2} .3410154{col 46}{space 1}    5.18{col 55}{space 3}0.000{col 63}{space 4} 1.096906{col 76}{space 3} 2.433662
{txt}{space 17}150  {c |}{col 23}{res}{space 2} 3.534359{col 35}{space 2} .3526691{col 46}{space 1}   10.02{col 55}{space 3}0.000{col 63}{space 4}  2.84314{col 76}{space 3} 4.225577
{txt}{space 17}155  {c |}{col 23}{res}{space 2} 1.057825{col 35}{space 2} .2496796{col 46}{space 1}    4.24{col 55}{space 3}0.000{col 63}{space 4} .5684623{col 76}{space 3} 1.547188
{txt}{space 17}165  {c |}{col 23}{res}{space 2} 2.902401{col 35}{space 2} .4164596{col 46}{space 1}    6.97{col 55}{space 3}0.000{col 63}{space 4} 2.086156{col 76}{space 3} 3.718647
{txt}{space 17}344  {c |}{col 23}{res}{space 2} 1.520989{col 35}{space 2} .2700733{col 46}{space 1}    5.63{col 55}{space 3}0.000{col 63}{space 4} .9916554{col 76}{space 3} 2.050323
{txt}{space 17}345  {c |}{col 23}{res}{space 2} 2.531926{col 35}{space 2} .3967166{col 46}{space 1}    6.38{col 55}{space 3}0.000{col 63}{space 4} 1.754376{col 76}{space 3} 3.309476
{txt}{space 17}355  {c |}{col 23}{res}{space 2} .6958669{col 35}{space 2} .2416789{col 46}{space 1}    2.88{col 55}{space 3}0.004{col 63}{space 4}  .222185{col 76}{space 3} 1.169549
{txt}{space 17}360  {c |}{col 23}{res}{space 2} 1.491789{col 35}{space 2} .2064668{col 46}{space 1}    7.23{col 55}{space 3}0.000{col 63}{space 4} 1.087122{col 76}{space 3} 1.896457
{txt}{space 17}365  {c |}{col 23}{res}{space 2} 1.981438{col 35}{space 2} .3673614{col 46}{space 1}    5.39{col 55}{space 3}0.000{col 63}{space 4} 1.261423{col 76}{space 3} 2.701453
{txt}{space 17}367  {c |}{col 23}{res}{space 2} 1.382109{col 35}{space 2} .3928682{col 46}{space 1}    3.52{col 55}{space 3}0.000{col 63}{space 4} .6121018{col 76}{space 3} 2.152117
{txt}{space 17}369  {c |}{col 23}{res}{space 2} 1.003109{col 35}{space 2} .2348573{col 46}{space 1}    4.27{col 55}{space 3}0.000{col 63}{space 4} .5427967{col 76}{space 3}  1.46342
{txt}{space 17}370  {c |}{col 23}{res}{space 2} 1.666996{col 35}{space 2} .1885472{col 46}{space 1}    8.84{col 55}{space 3}0.000{col 63}{space 4} 1.297451{col 76}{space 3} 2.036542
{txt}{space 17}373  {c |}{col 23}{res}{space 2} 1.526805{col 35}{space 2} .2475039{col 46}{space 1}    6.17{col 55}{space 3}0.000{col 63}{space 4} 1.041706{col 76}{space 3} 2.011904
{txt}{space 17}404  {c |}{col 23}{res}{space 2} .7280393{col 35}{space 2} .3745615{col 46}{space 1}    1.94{col 55}{space 3}0.052{col 63}{space 4}-.0060877{col 76}{space 3} 1.462166
{txt}{space 17}420  {c |}{col 23}{res}{space 2} 2.315053{col 35}{space 2} .3064645{col 46}{space 1}    7.55{col 55}{space 3}0.000{col 63}{space 4} 1.714394{col 76}{space 3} 2.915713
{txt}{space 17}432  {c |}{col 23}{res}{space 2} 2.275396{col 35}{space 2} .3605489{col 46}{space 1}    6.31{col 55}{space 3}0.000{col 63}{space 4} 1.568734{col 76}{space 3} 2.982059
{txt}{space 17}434  {c |}{col 23}{res}{space 2}  1.30113{col 35}{space 2} .3573292{col 46}{space 1}    3.64{col 55}{space 3}0.000{col 63}{space 4} .6007774{col 76}{space 3} 2.001482
{txt}{space 17}435  {c |}{col 23}{res}{space 2} .3902019{col 35}{space 2} .2089611{col 46}{space 1}    1.87{col 55}{space 3}0.062{col 63}{space 4}-.0193544{col 76}{space 3} .7997581
{txt}{space 17}436  {c |}{col 23}{res}{space 2}  2.60234{col 35}{space 2} .3436653{col 46}{space 1}    7.57{col 55}{space 3}0.000{col 63}{space 4} 1.928768{col 76}{space 3} 3.275911
{txt}{space 17}437  {c |}{col 23}{res}{space 2} .6048589{col 35}{space 2} .2021512{col 46}{space 1}    2.99{col 55}{space 3}0.003{col 63}{space 4} .2086498{col 76}{space 3} 1.001068
{txt}{space 17}438  {c |}{col 23}{res}{space 2} 1.246996{col 35}{space 2} .2655279{col 46}{space 1}    4.70{col 55}{space 3}0.000{col 63}{space 4}  .726571{col 76}{space 3} 1.767421
{txt}{space 17}450  {c |}{col 23}{res}{space 2} 1.013657{col 35}{space 2} .3202073{col 46}{space 1}    3.17{col 55}{space 3}0.002{col 63}{space 4} .3860618{col 76}{space 3} 1.641251
{txt}{space 17}451  {c |}{col 23}{res}{space 2} 1.316387{col 35}{space 2} .2952134{col 46}{space 1}    4.46{col 55}{space 3}0.000{col 63}{space 4} .7377791{col 76}{space 3} 1.894995
{txt}{space 17}461  {c |}{col 23}{res}{space 2} 3.067683{col 35}{space 2} .2557985{col 46}{space 1}   11.99{col 55}{space 3}0.000{col 63}{space 4} 2.566327{col 76}{space 3} 3.569039
{txt}{space 17}471  {c |}{col 23}{res}{space 2} .9068278{col 35}{space 2} .2417721{col 46}{space 1}    3.75{col 55}{space 3}0.000{col 63}{space 4} .4329631{col 76}{space 3} 1.380692
{txt}{space 17}475  {c |}{col 23}{res}{space 2} 2.198318{col 35}{space 2} .3870656{col 46}{space 1}    5.68{col 55}{space 3}0.000{col 63}{space 4} 1.439683{col 76}{space 3} 2.956952
{txt}{space 17}482  {c |}{col 23}{res}{space 2} 1.262616{col 35}{space 2} .3032404{col 46}{space 1}    4.16{col 55}{space 3}0.000{col 63}{space 4} .6682756{col 76}{space 3} 1.856956
{txt}{space 17}484  {c |}{col 23}{res}{space 2} .3122265{col 35}{space 2} .2161618{col 46}{space 1}    1.44{col 55}{space 3}0.149{col 63}{space 4} -.111443{col 76}{space 3} .7358959
{txt}{space 17}490  {c |}{col 23}{res}{space 2} 1.262972{col 35}{space 2} .3015086{col 46}{space 1}    4.19{col 55}{space 3}0.000{col 63}{space 4} .6720257{col 76}{space 3} 1.853918
{txt}{space 17}500  {c |}{col 23}{res}{space 2} .7452199{col 35}{space 2} .2965053{col 46}{space 1}    2.51{col 55}{space 3}0.012{col 63}{space 4} .1640802{col 76}{space 3}  1.32636
{txt}{space 17}501  {c |}{col 23}{res}{space 2} 1.806108{col 35}{space 2} .2721753{col 46}{space 1}    6.64{col 55}{space 3}0.000{col 63}{space 4} 1.272654{col 76}{space 3} 2.339562
{txt}{space 17}510  {c |}{col 23}{res}{space 2} 1.752397{col 35}{space 2} .2463309{col 46}{space 1}    7.11{col 55}{space 3}0.000{col 63}{space 4} 1.269597{col 76}{space 3} 2.235196
{txt}{space 17}516  {c |}{col 23}{res}{space 2} 2.267941{col 35}{space 2} .3677224{col 46}{space 1}    6.17{col 55}{space 3}0.000{col 63}{space 4} 1.547219{col 76}{space 3} 2.988664
{txt}{space 17}517  {c |}{col 23}{res}{space 2}-.5762337{col 35}{space 2} .2924709{col 46}{space 1}   -1.97{col 55}{space 3}0.049{col 63}{space 4}-1.149466{col 76}{space 3}-.0030013
{txt}{space 17}520  {c |}{col 23}{res}{space 2}   3.9191{col 35}{space 2} .3567684{col 46}{space 1}   10.98{col 55}{space 3}0.000{col 63}{space 4} 3.219847{col 76}{space 3} 4.618354
{txt}{space 17}531  {c |}{col 23}{res}{space 2} 1.394962{col 35}{space 2} .2741513{col 46}{space 1}    5.09{col 55}{space 3}0.000{col 63}{space 4} .8576352{col 76}{space 3} 1.932289
{txt}{space 17}551  {c |}{col 23}{res}{space 2}  1.74026{col 35}{space 2} .2641864{col 46}{space 1}    6.59{col 55}{space 3}0.000{col 63}{space 4} 1.222465{col 76}{space 3} 2.258056
{txt}{space 17}552  {c |}{col 23}{res}{space 2} 1.977207{col 35}{space 2} .2372078{col 46}{space 1}    8.34{col 55}{space 3}0.000{col 63}{space 4} 1.512288{col 76}{space 3} 2.442125
{txt}{space 17}553  {c |}{col 23}{res}{space 2} 1.437208{col 35}{space 2} .2924274{col 46}{space 1}    4.91{col 55}{space 3}0.000{col 63}{space 4} .8640611{col 76}{space 3} 2.010355
{txt}{space 17}560  {c |}{col 23}{res}{space 2}  3.16665{col 35}{space 2}  .365967{col 46}{space 1}    8.65{col 55}{space 3}0.000{col 63}{space 4} 2.449368{col 76}{space 3} 3.883932
{txt}{space 17}570  {c |}{col 23}{res}{space 2} 1.894469{col 35}{space 2} .2777235{col 46}{space 1}    6.82{col 55}{space 3}0.000{col 63}{space 4} 1.350141{col 76}{space 3} 2.438798
{txt}{space 17}580  {c |}{col 23}{res}{space 2} .1781498{col 35}{space 2} .3359979{col 46}{space 1}    0.53{col 55}{space 3}0.596{col 63}{space 4}-.4803939{col 76}{space 3} .8366936
{txt}{space 17}581  {c |}{col 23}{res}{space 2} 1.568974{col 35}{space 2} .3600226{col 46}{space 1}    4.36{col 55}{space 3}0.000{col 63}{space 4}  .863343{col 76}{space 3} 2.274605
{txt}{space 17}620  {c |}{col 23}{res}{space 2} 2.272095{col 35}{space 2} .3989695{col 46}{space 1}    5.69{col 55}{space 3}0.000{col 63}{space 4} 1.490129{col 76}{space 3} 3.054061
{txt}{space 17}625  {c |}{col 23}{res}{space 2}  3.23869{col 35}{space 2} .2604221{col 46}{space 1}   12.44{col 55}{space 3}0.000{col 63}{space 4} 2.728272{col 76}{space 3} 3.749108
{txt}{space 17}630  {c |}{col 23}{res}{space 2} 3.138237{col 35}{space 2} .3019421{col 46}{space 1}   10.39{col 55}{space 3}0.000{col 63}{space 4} 2.546442{col 76}{space 3} 3.730033
{txt}{space 17}640  {c |}{col 23}{res}{space 2} .9458515{col 35}{space 2} .3818387{col 46}{space 1}    2.48{col 55}{space 3}0.013{col 63}{space 4} .1974614{col 76}{space 3} 1.694242
{txt}{space 17}645  {c |}{col 23}{res}{space 2} 1.387978{col 35}{space 2} .3504463{col 46}{space 1}    3.96{col 55}{space 3}0.000{col 63}{space 4} .7011162{col 76}{space 3} 2.074841
{txt}{space 17}651  {c |}{col 23}{res}{space 2}-.8626638{col 35}{space 2} .3260227{col 46}{space 1}   -2.65{col 55}{space 3}0.008{col 63}{space 4}-1.501657{col 76}{space 3}-.2236712
{txt}{space 17}652  {c |}{col 23}{res}{space 2} 3.309149{col 35}{space 2} .3131725{col 46}{space 1}   10.57{col 55}{space 3}0.000{col 63}{space 4} 2.695342{col 76}{space 3} 3.922955
{txt}{space 17}660  {c |}{col 23}{res}{space 2} 1.656114{col 35}{space 2} .3319584{col 46}{space 1}    4.99{col 55}{space 3}0.000{col 63}{space 4} 1.005488{col 76}{space 3} 2.306741
{txt}{space 17}663  {c |}{col 23}{res}{space 2} 1.712229{col 35}{space 2} .2137086{col 46}{space 1}    8.01{col 55}{space 3}0.000{col 63}{space 4} 1.293368{col 76}{space 3}  2.13109
{txt}{space 17}666  {c |}{col 23}{res}{space 2} .8686312{col 35}{space 2} .4425495{col 46}{space 1}    1.96{col 55}{space 3}0.050{col 63}{space 4} .0012501{col 76}{space 3} 1.736012
{txt}{space 17}679  {c |}{col 23}{res}{space 2} 2.113181{col 35}{space 2} .2343032{col 46}{space 1}    9.02{col 55}{space 3}0.000{col 63}{space 4} 1.653955{col 76}{space 3} 2.572407
{txt}{space 17}700  {c |}{col 23}{res}{space 2} 1.842646{col 35}{space 2} .3911051{col 46}{space 1}    4.71{col 55}{space 3}0.000{col 63}{space 4} 1.076094{col 76}{space 3} 2.609198
{txt}{space 17}704  {c |}{col 23}{res}{space 2} .8762928{col 35}{space 2} .2603123{col 46}{space 1}    3.37{col 55}{space 3}0.001{col 63}{space 4}   .36609{col 76}{space 3} 1.386496
{txt}{space 17}710  {c |}{col 23}{res}{space 2} 3.277907{col 35}{space 2} .5825547{col 46}{space 1}    5.63{col 55}{space 3}0.000{col 63}{space 4} 2.136121{col 76}{space 3} 4.419694
{txt}{space 17}731  {c |}{col 23}{res}{space 2}  3.11619{col 35}{space 2} .3740782{col 46}{space 1}    8.33{col 55}{space 3}0.000{col 63}{space 4}  2.38301{col 76}{space 3}  3.84937
{txt}{space 17}750  {c |}{col 23}{res}{space 2} 1.722221{col 35}{space 2} .4570024{col 46}{space 1}    3.77{col 55}{space 3}0.000{col 63}{space 4} .8265128{col 76}{space 3} 2.617929
{txt}{space 17}770  {c |}{col 23}{res}{space 2} 4.213898{col 35}{space 2} .4243966{col 46}{space 1}    9.93{col 55}{space 3}0.000{col 63}{space 4} 3.382096{col 76}{space 3}   5.0457
{txt}{space 17}775  {c |}{col 23}{res}{space 2} 3.271321{col 35}{space 2} .3482636{col 46}{space 1}    9.39{col 55}{space 3}0.000{col 63}{space 4} 2.588737{col 76}{space 3} 3.953905
{txt}{space 17}780  {c |}{col 23}{res}{space 2} .5091746{col 35}{space 2} .3461861{col 46}{space 1}    1.47{col 55}{space 3}0.141{col 63}{space 4}-.1693377{col 76}{space 3} 1.187687
{txt}{space 17}790  {c |}{col 23}{res}{space 2} .6743659{col 35}{space 2} .2853054{col 46}{space 1}    2.36{col 55}{space 3}0.018{col 63}{space 4} .1151776{col 76}{space 3} 1.233554
{txt}{space 17}800  {c |}{col 23}{res}{space 2} 1.237656{col 35}{space 2} .3490332{col 46}{space 1}    3.55{col 55}{space 3}0.000{col 63}{space 4} .5535637{col 76}{space 3} 1.921749
{txt}{space 17}811  {c |}{col 23}{res}{space 2} 2.279277{col 35}{space 2} .2936674{col 46}{space 1}    7.76{col 55}{space 3}0.000{col 63}{space 4} 1.703699{col 76}{space 3} 2.854854
{txt}{space 17}812  {c |}{col 23}{res}{space 2} 1.107946{col 35}{space 2} .2659647{col 46}{space 1}    4.17{col 55}{space 3}0.000{col 63}{space 4}  .586665{col 76}{space 3} 1.629228
{txt}{space 17}850  {c |}{col 23}{res}{space 2} 1.881796{col 35}{space 2}  .348443{col 46}{space 1}    5.40{col 55}{space 3}0.000{col 63}{space 4} 1.198861{col 76}{space 3} 2.564732
{txt}{space 17}950  {c |}{col 23}{res}{space 2} 2.093657{col 35}{space 2} .2969436{col 46}{space 1}    7.05{col 55}{space 3}0.000{col 63}{space 4} 1.511658{col 76}{space 3} 2.675656
{txt}{space 21} {c |}
{space 17}year {c |}
{space 16}1991  {c |}{col 23}{res}{space 2} .2394216{col 35}{space 2} .2082222{col 46}{space 1}    1.15{col 55}{space 3}0.250{col 63}{space 4}-.1686863{col 76}{space 3} .6475296
{txt}{space 16}1992  {c |}{col 23}{res}{space 2} .4558194{col 35}{space 2} .2281102{col 46}{space 1}    2.00{col 55}{space 3}0.046{col 63}{space 4} .0087317{col 76}{space 3} .9029072
{txt}{space 16}1993  {c |}{col 23}{res}{space 2} .3645881{col 35}{space 2} .2136297{col 46}{space 1}    1.71{col 55}{space 3}0.088{col 63}{space 4}-.0541184{col 76}{space 3} .7832945
{txt}{space 16}1994  {c |}{col 23}{res}{space 2} .2486184{col 35}{space 2} .2303905{col 46}{space 1}    1.08{col 55}{space 3}0.281{col 63}{space 4}-.2029387{col 76}{space 3} .7001755
{txt}{space 16}1995  {c |}{col 23}{res}{space 2} .2059749{col 35}{space 2} .2390473{col 46}{space 1}    0.86{col 55}{space 3}0.389{col 63}{space 4}-.2625493{col 76}{space 3}  .674499
{txt}{space 16}1996  {c |}{col 23}{res}{space 2} .2751198{col 35}{space 2} .2691863{col 46}{space 1}    1.02{col 55}{space 3}0.307{col 63}{space 4}-.2524757{col 76}{space 3} .8027153
{txt}{space 16}1997  {c |}{col 23}{res}{space 2} .4344982{col 35}{space 2} .2684743{col 46}{space 1}    1.62{col 55}{space 3}0.106{col 63}{space 4}-.0917017{col 76}{space 3} .9606981
{txt}{space 16}1998  {c |}{col 23}{res}{space 2} .4675529{col 35}{space 2} .2776062{col 46}{space 1}    1.68{col 55}{space 3}0.092{col 63}{space 4}-.0765452{col 76}{space 3} 1.011651
{txt}{space 16}1999  {c |}{col 23}{res}{space 2} .2907043{col 35}{space 2} .2856795{col 46}{space 1}    1.02{col 55}{space 3}0.309{col 63}{space 4}-.2692172{col 76}{space 3} .8506258
{txt}{space 16}2000  {c |}{col 23}{res}{space 2} .8476719{col 35}{space 2} .2991368{col 46}{space 1}    2.83{col 55}{space 3}0.005{col 63}{space 4} .2613745{col 76}{space 3} 1.433969
{txt}{space 16}2001  {c |}{col 23}{res}{space 2} .9664861{col 35}{space 2}  .291564{col 46}{space 1}    3.31{col 55}{space 3}0.001{col 63}{space 4} .3950312{col 76}{space 3} 1.537941
{txt}{space 16}2002  {c |}{col 23}{res}{space 2} 1.530953{col 35}{space 2} .2880132{col 46}{space 1}    5.32{col 55}{space 3}0.000{col 63}{space 4} .9664576{col 76}{space 3} 2.095448
{txt}{space 16}2003  {c |}{col 23}{res}{space 2} 1.627346{col 35}{space 2} .3036998{col 46}{space 1}    5.36{col 55}{space 3}0.000{col 63}{space 4} 1.032105{col 76}{space 3} 2.222587
{txt}{space 16}2004  {c |}{col 23}{res}{space 2} .9041937{col 35}{space 2} .2968504{col 46}{space 1}    3.05{col 55}{space 3}0.002{col 63}{space 4} .3223776{col 76}{space 3}  1.48601
{txt}{space 16}2005  {c |}{col 23}{res}{space 2} .8918497{col 35}{space 2} .2945854{col 46}{space 1}    3.03{col 55}{space 3}0.002{col 63}{space 4}  .314473{col 76}{space 3} 1.469226
{txt}{space 16}2006  {c |}{col 23}{res}{space 2} .6616749{col 35}{space 2} .3002315{col 46}{space 1}    2.20{col 55}{space 3}0.028{col 63}{space 4} .0732321{col 76}{space 3} 1.250118
{txt}{space 16}2007  {c |}{col 23}{res}{space 2} .3825076{col 35}{space 2} .3083518{col 46}{space 1}    1.24{col 55}{space 3}0.215{col 63}{space 4}-.2218509{col 76}{space 3}  .986866
{txt}{space 16}2008  {c |}{col 23}{res}{space 2} .4435135{col 35}{space 2} .3204792{col 46}{space 1}    1.38{col 55}{space 3}0.166{col 63}{space 4}-.1846142{col 76}{space 3} 1.071641
{txt}{space 21} {c |}
{space 16}_cons {c |}{col 23}{res}{space 2} -3.30332{col 35}{space 2} .9963763{col 46}{space 1}   -3.32{col 55}{space 3}0.001{col 63}{space 4}-5.256182{col 76}{space 3}-1.350459
{txt}{hline 22}{c BT}{hline 11}{hline 11}{hline 9}{hline 8}{hline 13}{hline 12}

{com}. 
. *Predictions
. predict onsUS_logistic
{txt}(444 missing values generated)

{com}. gen prob_sanc_onsUS_logistic = 1/(1+exp(-onsUS_logistic))
{txt}(444 missing values generated)

{com}. gen bin_prob_sanc_onsUS_logistic = cond(prob_sanc_onsUS_logistic > .5, 1,0)
{txt}
{com}. replace bin_prob_sanc_onsUS_logistic =. if missing(prob_sanc_onsUS_logistic)
{txt}(444 real changes made, 444 to missing)

{com}. 
. * Confusion Matrix
. * Sensitivity 61.8, Specificity 86
. diagtest sanction_test bin_prob_sanc_onsUS_logistic

           {txt}{c |} bin_prob_sanc_onsUS_l
sanction_t {c |}        ogistic
       est {c |}         0          1 {c |}     Total
{hline 11}{c +}{hline 22}{c +}{hline 10}
         0 {c |}{res}       674         52 {txt}{c |}{res}       726 
{txt}         1 {c |}{res}       110         84 {txt}{c |}{res}       194 
{txt}{hline 11}{c +}{hline 22}{c +}{hline 10}
     Total {c |}{res}       784        136 {txt}{c |}{res}       920 

{txt}True D defined as bin_prob_sanc_onsUS_logistic ~= 0   [95% Conf. Inter.]
-------------------------------------------------------------------------
Sensitivity                     Pr( +| D)  {res}61.76%      58.62%   64.90%
{txt}Specificity                     Pr( -|~D)  {res}85.97%      83.73%   88.21%
{txt}Positive predictive value       Pr( D| +)  {res}43.30%      40.10%   46.50%
{txt}Negative predictive value       Pr(~D| -)  {res}92.84%      91.17%   94.50%
{txt}-------------------------------------------------------------------------
Prevalence                      Pr(D)      {res}14.78%      12.49%   17.08%
{txt}-------------------------------------------------------------------------

{com}. tab2xl sanction_test bin_prob_sanc_onsUS_logistic using Supplemental_Material\Prediction_Output\Confusion_Matrixes\US_Imposition_PMLFE, col(1) row(1)
{res}{txt}file {bf:Supplemental_Material\Prediction_Output\Confusion_Matrixes\US_Imposition_PMLFE.xlsx} saved

{com}. 
. * Evaluation
. *Kappa .41
. kap sanction_test bin_prob_sanc_onsUS_logistic

{txt}{col 14}Expected
Agreement   agreement     Kappa   Std. err.         Z      Prob>Z
{hline 65}
{res}  82.39%      70.36%     0.4058     0.0322      12.60      0.0000
{txt}
{com}. * AUPR .64
. prtab sanction_test prob_sanc_onsUS_logistic, title("US", box bexpand) 

{txt}{col 12}Number of observations       =  {res}920
{txt}{col 12}Unique values of classifier  =  {res}920
{txt}{col 12}Number of positive cases     =  {res}194
{txt}{col 12}Portion of positive cases    ={res}  0.2109

{txt}{hline 50}
{col 5} Recall =  0.1031{col 25}  0.2010{col 37}  0.3041
{hline 50}
{res}{col 2}Precision{col 14}  1.0000{col 25}  0.9750{col 37}  0.8939
{txt}{hline 50}
{res}
{txt}{col 2}Area under precision-recall curve:  0.6424

{com}. graph save "Graph" "Supplemental_Material\Prediction_Output\ROC-curves\AUPR_Imposition_PMLFE_US.gph", replace
{txt}{p 0 4 2}
(file {bf}
Supplemental_Material\Prediction_Output\ROC-curves\AUPR_Imposition_PMLFE_US.gph{rm}
not found)
{p_end}
{res}{txt}file {bf:Supplemental_Material\Prediction_Output\ROC-curves\AUPR_Imposition_PMLFE_US.gph} saved

{com}. 
. 
. * Random forest only for cases with data
. gen helper_sanction_test=sanction_test if!missing(prob_sanc_onsUS_logistic)
{txt}(2,861 missing values generated)

{com}. * Sensitivity 52.5, Specificity 86.7
. diagtest helper_sanction_test randonsUS

{txt}helper_san {c |}   predicted classes
ction_test {c |}         0          1 {c |}     Total
{hline 11}{c +}{hline 22}{c +}{hline 10}
         0 {c |}{res}       639         87 {txt}{c |}{res}       726 
{txt}         1 {c |}{res}        98         96 {txt}{c |}{res}       194 
{txt}{hline 11}{c +}{hline 22}{c +}{hline 10}
     Total {c |}{res}       737        183 {txt}{c |}{res}       920 

{txt}True D defined as randonsUS ~= 0                      [95% Conf. Inter.]
-------------------------------------------------------------------------
Sensitivity                     Pr( +| D)  {res}52.46%      49.23%   55.69%
{txt}Specificity                     Pr( -|~D)  {res}86.70%      84.51%   88.90%
{txt}Positive predictive value       Pr( D| +)  {res}49.48%      46.25%   52.72%
{txt}Negative predictive value       Pr(~D| -)  {res}88.02%      85.92%   90.12%
{txt}-------------------------------------------------------------------------
Prevalence                      Pr(D)      {res}19.89%      17.31%   22.47%
{txt}-------------------------------------------------------------------------

{com}. tab2xl helper_sanction_test randonsUS using Supplemental_Material\Prediction_Output\Confusion_Matrixes\US_Imposition_RF_lim_sample, col(1) row(1)
{res}{txt}file {bf:Supplemental_Material\Prediction_Output\Confusion_Matrixes\US_Imposition_RF_lim_sample.xlsx} saved

{com}. 
. * AUPR .51
. prtab helper_sanction_test randonsUS1
{txt}(2 missing values generated)

{col 12}Number of observations       =  {res}920
{txt}{col 12}Unique values of classifier  =  {res}861
{txt}{col 12}Number of positive cases     =  {res}194
{txt}{col 12}Portion of positive cases    ={res}  0.2109

{txt}{hline 50}
{col 5} Recall =  0.1031{col 25}  0.2010{col 37}  0.3041
{hline 50}
{res}{col 2}Precision{col 14}  0.7407{col 25}  0.6842{col 37}  0.6629
{txt}{hline 50}
{res}
{txt}{col 2}Area under precision-recall curve:  0.5118

{com}. graph save "Graph" "Supplemental_Material\Prediction_Output\ROC-curves\AUPR_Imposition_RF_US_lim_sample", replace
{txt}{p 0 4 2}
(file {bf}
Supplemental_Material\Prediction_Output\ROC-curves\AUPR_Imposition_RF_US_lim_sample.gph{rm}
not found)
{p_end}
{res}{txt}file {bf:Supplemental_Material\Prediction_Output\ROC-curves\AUPR_Imposition_RF_US_lim_sample.gph} saved

{com}. 
. * Kappa .38
. kap helper_sanction_test randonsUS

{txt}{col 14}Expected
Agreement   agreement     Kappa   Std. err.         Z      Prob>Z
{hline 65}
{res}  79.89%      67.41%     0.3830     0.0329      11.62      0.0000
{txt}
{com}. 
. log close
      {txt}name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\thies\OneDrive\00_Promotion\00_Output\00_Paper\2022_Predicting_Econ_Sanctions\Empirics\20231214_Replication\Log_files/01a_Imposition_limited_sample_US.smcl
  {txt}log type:  {res}smcl
 {txt}closed on:  {res}18 Dec 2023, 16:06:37
{txt}{.-}
{smcl}
{txt}{sf}{ul off}